#include "stdafx.h"

#include "hwincomcontrol.h"

namespace harlinn
{
    namespace windows
    {
        // IOleControl
        HWIN_EXPORT HRESULT ComControl::GetControlInfo(CONTROLINFO *pCI)
        {
            if (!pCI)
            {
                return E_INVALIDARG;
            }
            memset(pCI,0,sizeof(CONTROLINFO));
            pCI->cb = sizeof(CONTROLINFO); 

            auto control = GetControl();

            if (control->IsInputKey(Keys::Return)) 
            { 
                pCI->dwFlags |= CTRLINFO_EATS_RETURN;
            }
            if (control->IsInputKey(Keys::Escape)) 
            {
                pCI->dwFlags |= CTRLINFO_EATS_ESCAPE; 
            }
            return S_OK;
        }
        HWIN_EXPORT HRESULT ComControl::OnMnemonic(MSG *pMsg)
        {
            auto control = GetControl();
            control->ProcessMnemonic((wchar_t)pMsg->wParam);
            return S_OK;
        }
        HWIN_EXPORT HRESULT ComControl::OnAmbientPropertyChange(DISPID dispID)
        {
            return S_OK;
        }
        HWIN_EXPORT HRESULT ComControl::FreezeEvents(BOOL bFreeze)
        {
            return S_OK;
        }

        // IOleObject
        HWIN_EXPORT HRESULT ComControl::SetClientSite(IOleClientSite *pClientSite)
        {
            oleClientSite.Reset(pClientSite,true);
            return S_OK;
        }
        HWIN_EXPORT HRESULT ComControl::GetClientSite(IOleClientSite **ppClientSite)
        {
            if (!ppClientSite)
            {
                return E_INVALIDARG;
            }
            *ppClientSite = oleClientSite;
            if(*ppClientSite)
            {
                (*ppClientSite)->AddRef();
            }

            return S_OK;
        }
        HWIN_EXPORT HRESULT ComControl::SetHostNames( LPCOLESTR szContainerApp, LPCOLESTR szContainerObj)
        {
            return S_OK;
        }
        HWIN_EXPORT HRESULT ComControl::Close(DWORD dwSaveOption )
        {
            return S_OK;
        }
        HWIN_EXPORT HRESULT ComControl::SetMoniker(DWORD dwWhichMoniker,IMoniker *pmk)
        {
            return E_NOTIMPL; // OK
        }
        HWIN_EXPORT HRESULT ComControl::GetMoniker( DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk)
        {
            return E_NOTIMPL; // OK
        }
        HWIN_EXPORT HRESULT ComControl::InitFromData( IDataObject *pDataObject, BOOL fCreation, DWORD dwReserved)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::GetClipboardData( DWORD dwReserved, IDataObject **ppDataObject)
        {
            if(ppDataObject)
            {
                *ppDataObject = nullptr;
            }
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::DoVerb( LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect)
        {

            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::EnumVerbs( IEnumOLEVERB **ppEnumOleVerb )
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::Update( )
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::IsUpToDate( )
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::GetUserClassID( CLSID *pClsid)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::GetUserType( DWORD dwFormOfType,LPOLESTR *pszUserType)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::SetExtent( DWORD dwDrawAspect,SIZEL *psizel)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::GetExtent( DWORD dwDrawAspect,SIZEL *psizel)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::Advise( IAdviseSink *pAdvSink,DWORD *pdwConnection)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::Unadvise( DWORD dwConnection)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::EnumAdvise( IEnumSTATDATA **ppenumAdvise)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::GetMiscStatus( DWORD dwAspect, DWORD *pdwStatus)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::SetColorScheme( LOGPALETTE *pLogpal)
        {
            return E_NOTIMPL;
        }

        // IOleInPlaceObject
        HWIN_EXPORT HRESULT ComControl::InPlaceDeactivate( )
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::UIDeactivate( )
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::SetObjectRects( LPCRECT lprcPosRect, LPCRECT lprcClipRect)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::ReactivateAndUndo( )
        {
            return E_NOTIMPL;
        }

        // IOleInPlaceActiveObject
        HWIN_EXPORT HRESULT ComControl::TranslateAccelerator(LPMSG lpmsg)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::OnFrameWindowActivate(BOOL fActivate)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::OnDocWindowActivate( BOOL fActivate)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::ResizeBorder(LPCRECT prcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fFrameWindow)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::EnableModeless(BOOL fEnable)
        {
            return E_NOTIMPL;
        }

        // IOleWindow
        HWIN_EXPORT HRESULT ComControl::GetWindow(HWND *phwnd)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::ContextSensitiveHelp(BOOL fEnterMode)
        {
            return E_NOTIMPL;
        }

        // IViewObject
        HWIN_EXPORT HRESULT ComControl::Draw( DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds, BOOL ( STDMETHODCALLTYPE *pfnContinue )( ULONG_PTR dwContinue), ULONG_PTR dwContinue)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::GetColorSet( DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::Freeze( DWORD dwDrawAspect, LONG lindex, void *pvAspect, DWORD *pdwFreeze)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::Unfreeze( DWORD dwFreeze)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::SetAdvise( DWORD aspects,DWORD advf,IAdviseSink *pAdvSink)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::GetAdvise( DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink)
        {
            return E_NOTIMPL;
        }

        // IViewObject2
        HWIN_EXPORT HRESULT ComControl::GetExtent( DWORD dwDrawAspect, LONG lindex, DVTARGETDEVICE *ptd, LPSIZEL lpsizel)
        {
            return E_NOTIMPL;
        }

        // IPersist
        HWIN_EXPORT HRESULT ComControl::GetClassID(CLSID *pClassID)
        {
            return E_NOTIMPL;
        }

        // IPersistStreamInit
        HWIN_EXPORT HRESULT ComControl::IsDirty( )
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::Load( LPSTREAM pStm)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::Save( LPSTREAM pStm, BOOL fClearDirty)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::GetSizeMax(ULARGE_INTEGER *pCbSize)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::InitNew( )
        {
            return E_NOTIMPL;
        }

        HWIN_EXPORT HRESULT ComControl::Load( IPropertyBag *pPropBag, IErrorLog *pErrorLog)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::Save( IPropertyBag *pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties)
        {
            return E_NOTIMPL;
        }

        HWIN_EXPORT HRESULT ComControl::InitNew(IStorage *pStg)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::Load(IStorage *pStg )
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::Save( IStorage *pStgSave, BOOL fSameAsLoad)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::SaveCompleted( IStorage *pStgNew)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::HandsOffStorage( )
        {
            return E_NOTIMPL;
        }

        // IQuickActivate
        HWIN_EXPORT HRESULT ComControl::QuickActivate( QACONTAINER *pQaContainer, QACONTROL *pQaControl)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::SetContentExtent(LPSIZEL pSizel)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::GetContentExtent(LPSIZEL pSizel)
        {
            return E_NOTIMPL;
        }

        // IDropTarget
        HWIN_EXPORT HRESULT ComControl::DragEnter( IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::DragOver( DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::DragLeave( )
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::Drop( IDataObject *pDataObj,DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
        {
            return E_NOTIMPL;
        }

        // IDropSource
        HWIN_EXPORT HRESULT ComControl::QueryContinueDrag( BOOL fEscapePressed, DWORD grfKeyState)
        {
            return E_NOTIMPL;
        }
        HWIN_EXPORT HRESULT ComControl::GiveFeedback( DWORD dwEffect)
        {
            return E_NOTIMPL;
        }


    };
};